package com.niit.mall.api.fallback;



import com.niit.mall.api.client.UserClient;
import com.niit.mall.common.api.CommonResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @BelongsProject: pardo_mall_backend
 * @BelongsPackage: com.niit.mall.api.fallback
 * @Author: ChuXuan
 * @CreateTime: 2025-06-08  02:45
 * @Description: 用户服务降级处理
 * @Version: 1.0
 */
@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
	@Override
	public UserClient create(Throwable throwable) {
		return new UserClient() {
			@Override
			public CommonResult<Void> reduceBalance(Double totalPrice) {
				log.error("调用用户服务失败，降级处理，原因：{}", throwable.getMessage());
				return CommonResult.failed("调用用户服务失败");

			}
		};
	}
}
